 /* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhave.client;

import javax.swing.*;
import java.util.*;
import java.awt.*;
import org.jdom.Element;

/**
 *
 * @author bosmak40
 */
public class Textarea_Default_Line_Element extends JHAVE_Abstract_TextArea_Element implements JHAVE_Element{

    String lastValueEntered;
    Boolean sameAlgorithm;

    Textarea_Default_Line_Element(Element child, JPanel returnedPanel, Vector components, String lastValueEntered, Boolean sameAlgorithm){
        super(child, returnedPanel, components);
	this.lastValueEntered = lastValueEntered;
	this.sameAlgorithm = sameAlgorithm;
    }

     /**
     * Adds Textfield default line element to panel and to components vector.
     *
     */
    public void addElementToPanel(){
        //if the same algorithm is ran twice paste in the old value entered
	if (sameAlgorithm)
	{
	    textArea = new JTextArea( lastValueEntered,25,80);
	    txt_child.getText();
	    //set sameAlg (bool) back to default value.
	    sameAlgorithm = false;
	}
	//else put in default value
	else
	{
	    textArea = new JTextArea( txt_child.getText(),25,80 );
	}
        JPanel panel = new JPanel();
        panel.add(textArea);
        JButton loadFile = new JButton("Load File");
        panel.add(loadFile);
        TextJScrollPane scrollPane =
            new TextJScrollPane(panel, textArea, loadFile); // A helper class
        //			    new TextJScrollPane(textArea); // A helper class defined below
        this.components.add(scrollPane);
        this.returnedPanel.add(scrollPane);
    }

}